import renderParse from "@/components/low-code/parse/index.vue";
import pageRender from "../render/index.vue";
import { ComponentImp, LowCode } from "@/components/low-code/core";
import { components as componentMapping } from "@/components/low-code/pc-library/index";


type Params = { custom: { config:ComponentImp; widget: any; setting: any }[] };
const install = function (app: any, opts: Params) {
  app.component("renderParse", renderParse);
  app.component("pageRender", pageRender);

  /****
   * 注册自定义组件
   */
  if (opts?.custom && opts?.custom.length > 0) {
    LowCode.custom = opts?.custom;
    console.log(opts.custom);
    opts.custom.map((item) => {
        componentMapping.set(item.config.component, {
          widget: item.widget,
        } as any);
      });
  }
};

export default install;
